<?php


namespace app\mweb\controller;


use app\sys\service\GateCli;
use think\facade\Validate;
use think\Request;

class Ws
{
    // 链接绑定
    public function wsBind(Request $request){
        $data = $request->param();
        $validate = Validate::make([
            "client_id|ws链接id" => "require",
        ]);
        if (!$validate->check($data)) {
            return failedJson($validate->getError());
        }
        $staffInfo = $request->_user;

        $stf = \app\admin\model\Staff::where("staff_no",$staffInfo["staff_no"])->find();
        $cli = new GateCli();
        $st = $cli -> wsStaffBind($data["client_id"],$staffInfo["staff_no"],$stf["id"],$staffInfo["device_id"]);
        if($st){
            return failedJson($st."绑定失败");
        }
        return successJson("success","绑定成功");
    }
}